//
//  YKApproveViewController.m
//  YunKang
//
//  Created by leoking870 on 2017/9/24.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKApproveViewController.h"
#import <TFSegmentConfigModel.h>
#import <TFSegmentView.h>
#import "YKApproveListViewController.h"
@interface YKApproveViewController ()

@end

@implementation YKApproveViewController
- (NSString *)searchPlaceholder {
    return @"请输入客户编码或名称";
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.segmentView.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"审批管理";
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(numberUpdated:) name:@"numberUpdated" object:nil];
}

- (void)numberUpdated:(NSNotification*)sender {
    self.segmentView.itemArr = @[[NSString stringWithFormat:@"待审批(%@)",sender.object],@"已审批"];
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}

- (NSArray *)titlesForViewControllers {
    return @[@"待审批",@"已审批"];
}

- (void)beginSearchWithText:(NSString *)text {
    YKApproveListViewController *viewController = (YKApproveListViewController *) [self currentViewController];
    viewController.c_name = text;
    [viewController startLoadDataSilently];
}

- (void)didScrollToIndex:(NSUInteger)index {
    YKApproveListViewController *viewController = (YKApproveListViewController *) [self currentViewController];
    viewController.c_name = [self searchText];

    [viewController startLoadDataSilently];
}

- (UIViewController *)viewControllerAtIndex:(NSUInteger)index {
    YKApproveListViewController *vc = [[YKApproveListViewController alloc] init];
    vc.c_name = [self searchText];
    if (index == 0) {
        vc.task_state = @"1";
    }
    else {
        vc.task_state = @"6";
    }
    return vc;
}

- (TFSegmentConfigModel *)segmentConfigModel {
    TFSegmentConfigModel* model = [[TFSegmentConfigModel  alloc]init];
    model.textColor = [UIColor tf_colorWithHexString:@"#040404"];
    model.selectedTextColor = TFSTYLE(buttonEnableBackgroundColor);
    model.lineColor = TFSTYLE(buttonEnableBackgroundColor);
    model.lineInsets = UIEdgeInsetsMake(42, 0, 0, 0);
    model.fillSegmentWithItemsWhenLessCount = YES;
    return model;
}

@end
